package com.example.dllo.baidumusic.adapter;
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         佛祖保佑       永无BUG
*/

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.dllo.baidumusic.R;
import com.example.dllo.baidumusic.bean.MusicBean;

import java.util.List;

/**
 * Created by dllo on 16/8/30.
 */
public class ListPopAdapter extends BaseAdapter {

    private List<MusicBean> musicBean;
    private Context mContext;

    public ListPopAdapter(Context mContext) {
        this.mContext = mContext;
    }


    public void setMusicBean(List<MusicBean> musicBean) {
        this.musicBean = musicBean;
    }

    @Override
    public int getCount() {
        return musicBean == null ? 0 : musicBean.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHoler viewHoler = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_pop_list, parent, false);
            viewHoler = new ViewHoler(convertView);
            convertView.setTag(viewHoler);
        } else {
            viewHoler = (ViewHoler) convertView.getTag();
        }

        viewHoler.singname.setText(musicBean.get(position).getMusicName());
        viewHoler.singer.setText(musicBean.get(position).getSingerName());

        return convertView;
    }

    public class ViewHoler {

        TextView singname;
        TextView singer;


        public ViewHoler(View convertView) {
            singname = (TextView) convertView.findViewById(R.id.item_pop_singname);
            singer = (TextView) convertView.findViewById(R.id.item_pop_singer);


        }
    }
}
